%   Copyright (c) [2023] [423109070325付志峰]
%   [春天的高等数学代码库] is licensed under Mulan PSL v2.
%   You can use this software according to the terms and conditions of the Mulan PSL v2. 
%   You may obtain a copy of Mulan PSL v2 at:
%            http://license.coscl.org.cn/MulanPSL2 
%   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
%   See the Mulan PSL v2 for more details. 
tic;
clear
%定义方程
x=input("请输入左区间：")
k=input("请输入右区间：")
f=@(x)x^2+3;%此处定义方程
df=@(x)2*x;%此处输入导函数
%求解方程
[k,x,f(x)];
while abs(f(x))>0.000001
    x=x-f(x)/df(x);
    k=k+1;
    [k,x,f(x)];
    %超时停止
    if toc>6
    error("Timeout:请检查方程中是否存在不存在的解")
    end
end
%得解
vpa(x,10)


